package com.monitor.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpSpecificationsMapper;
import com.monitor.entity.ErpSpecifications;
import com.monitor.service.ErpSpecificationsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 品名规格 服务实现类
 * </p>
 *
 * @author LX
 * @since 2018-09-20
 */
@Service
public class ErpSpecificationsServiceImpl extends ServiceImpl<ErpSpecificationsMapper, ErpSpecifications> implements ErpSpecificationsService {

    @Resource
    private ErpSpecificationsMapper specificationsMapper;

    @Override
    public ErpSpecifications getSpecifications(ErpSpecifications specifications) {
        if(null==specifications){
            return null;
        }

        List<ErpSpecifications> models=specificationsMapper.selectList(new EntityWrapper<ErpSpecifications>().eq("pid",specifications.getZid()));
        if(0==models.size()){
            return specifications;
        }

        for (ErpSpecifications m:models) {
            getSpecifications(m);
        }
        specifications.setSpecifications(models);
        return specifications;
    }

    @Override
    public List<ErpSpecifications> getSpecCustomerBycustIdList() {


        return    specificationsMapper.getSpecCustomerBycustIdList();
    }

}
